Once you've got the ABox all built and ready to go, you need to tell it to draw itself on the screen...
OSErr ABox::Draw(WindowPtr window);
You can pass nearly anything in the "window" argument; it is currently unused, and a "NULL" will work very nicely right now.
Now that the ABox is up and on the screen, you've got to allow it to receive events. You do this by using the method below in one of two ways
Boolean ABox::Event(EventRecord *event);
(1) Send it a NULL for the event; this will prime the ABox, and if you have instructed it to operate as a Modal Dialog, it will block until the Modal Dialog version of the ABox is dismissed by the user. Below is a sample:
gABox = new ABox;
if (gABox)
{
// PrepareABox is from the earlier example on
// setting properties
error = PrepareABox (gABox,
splashTime,
modality,
&homeSpec);
error = gABox->Draw(NULL);
error = gABox->Event(NULL);
}
OR
(2) Incorporate the ABox's Event method into your application's main event loop. This is generally the preferred method, as it allows the ABox to operate in any fashion--even as a splash screen. Below is a sample:
do
{
// Get an event...
WaitNextEvent(everyEvent,
&eRecord,
mySleep,
nil);
// if we have an ABox up and running,
// allow it first shot at the event
if (gABox)
{
Boolean aboxFinished = false;
aboxHandled = gABox->Event(&eRecord);
// is the ABox now finished?
error = gABox->GetProperty (kABoxIsFinished,
&aboxFinished,
NULL);
if (aboxFinished)
{
// yes, the ABox is done and over with
delete gABox;
gABox = NULL;
} else if (aboxHandled) {
// did the ABox handle the event? Should
// we further process it? Yes, if we
// are here...
continue;
} // end if block
} // end if block
// normal event processing here since either
// we don't have an ABox, the ABox is finished,
// or the ABox didn't want the event.
switch (eRecord.what)
{
// blah blah blah...
// general event handling here
} // end switch block
} while (gQuit != true);
That's about it... just remember to delete the ABox